Reduce the time required to start xm-test domains by allowing the console
authordanms@us.ibm.com <danms@us.ibm.com>
Tue, 15 Nov 2005 15:07:44 +0000 (16:07 +0100)
committerdanms@us.ibm.com <danms@us.ibm.com>
Tue, 15 Nov 2005 15:07:44 +0000 (16:07 +0100)
to retry connecting to the DomU multiple times.  A polling approach instead
of a wait-and-hope-it-works approach.

tools/xm-test/lib/XmTestLib/Console.py
tools/xm-test/lib/XmTestLib/XenDomain.py

index 0e34bcf5c81557330646e5a09cc9ffae9f1e3c79..3c5691dc960941482e790f42dde02ab1e5ef614e 100755 (executable)
@@ -62,26 +62,37 @@ class XmConsole:
         self.historySaveCmds  = historySaveCmds
         self.debugMe          = False
         self.limit            = None
+        self.delay            = 2
 
         consoleCmd = ["/usr/sbin/xm", "xm", "console", domain]
 
-        if verbose:
-            print "Console executing: " + str(consoleCmd)
+        start = time.time()
+
+        while (time.time() - start) < self.TIMEOUT:
+            if verbose:
+                print "Console executing: %s" % str(consoleCmd)
 
-        pid, fd = pty.fork()
+            pid, fd = pty.fork()
 
-        if pid == 0:
-            os.execvp("/usr/sbin/xm", consoleCmd[1:])
+            if pid == 0:
+                os.execvp("/usr/sbin/xm", consoleCmd[1:])
 
-        self.consolePid = pid
-        self.consoleFd  = fd
+            self.consolePid = pid
+            self.consoleFd  = fd
 
-        tty.setraw(self.consoleFd, termios.TCSANOW)
+            tty.setraw(self.consoleFd, termios.TCSANOW)
             
-        bytes = self.__chewall(self.consoleFd)
-        if bytes < 0:
-            raise ConsoleError("Console didn't respond")
+            bytes = self.__chewall(self.consoleFd)
+
+            if bytes > 0:
+                return
 
+            if verbose:
+                print "Console didn't attach, waiting %i sec..." % self.delay
+            time.sleep(self.delay)
+
+        raise ConsoleError("Console didn't respond after %i secs" % self.TIMEOUT)
+    
     def __addToHistory(self, line):
         self.historyBuffer.append(line)
         self.historyLines += 1
index 6a8145ee84ece40fccdd6e50670e141f222cccb7..7bacf2b68321a23c18659bdf3f471ca6accb75b5 100644 (file)
@@ -228,7 +228,7 @@ class XmTestDomain(XenDomain):
 #            status, output = traceCommand("xm list")
 
         XenDomain.start(self)
-        waitForBoot()
+#        waitForBoot()
 
     def startNow(self):
         XenDomain.start(self)